﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace LaoLuo
{
    internal static class Worker
    {
        public static void Do<T>(Action<T> action, IEnumerable<Work<T>> work)
        {
            foreach (var item in work)
            {
                if (item.Immediate)
                {
                    action(item.WorkObject);
                }
                else
                {
                    if (item.WorkTime.HasValue)
                    {
                        TimerOneTime.WorkOnTime(() =>
                        {
                            action(item.WorkObject);
                        }, item.WorkTime.Value);
                    }
                }
            }
        }
    }
}
